<%@ Page Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" ValidateRequest="false" AutoEventWireup="true" CodeFile="EditProduct.aspx.cs" Inherits="Admin_EditProduct" Title="Untitled Page" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<%@ Register Assembly="FreeTextBox" Namespace="FreeTextBoxControls" TagPrefix="FTB" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderAdmin" Runat="Server">
    <telerik:RadScriptManager ID="ScriptManager1" runat="server" EnableTheming="True">
    </telerik:RadScriptManager>

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ddlstWareHouse">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ddlstCategory" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ddlstCategory">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ddlstProduct" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ddlstProduct">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="DetailsView1" />
                </UpdatedControls>
            </telerik:AjaxSetting>                       
        </AjaxSettings>
    </telerik:RadAjaxManager>

<h3 id="title">Quick Edit Product</h3>

<table cellspacing="10">
    <tr>
        <td>
            <b>Choose WareHouse</b>
        </td>
        <td style="text-align:left">
            <asp:DropDownList ID="ddlstWareHouse" runat="server" DataSourceID="ObjectDataSourceWareHouse" Width="300px"
                                DataTextField="WarehouseName" DataValueField="WarehouseID" AutoPostBack="True"  />
        </td>
        <td rowspan="5" align="center">
            <asp:Image ID="previewImage" runat="server" Visible="false"/>
        </td>
    </tr>
    <tr>
        <td>
            <b>Choose Category</b>
        </td>
        <td style="text-align:left">
            <asp:DropDownList ID="ddlstCategory" runat="server" DataSourceID="ObjectDataSourceCategory" Width="300px"
                                DataTextField="CategoryName" DataValueField="CategoryID" AutoPostBack="True"  />
        </td>
    </tr>
    <tr>
        <td>
            <b>Choose Product</b>
        </td>
        <td style="text-align:left">
            <asp:DropDownList ID="ddlstProduct" runat="server" DataSourceID="ObjectDataSourceProduct" Width="300px"
                                DataTextField="ProductName" DataValueField="ProductID" AutoPostBack="True" />
        </td>
    </tr>
    <tr>
        <td>
            <b>Update Images : </b>
        </td>
        <td style="text-align:left">
            <asp:FileUpload ID="myFile" runat="server" />
            
        </td>
    </tr>
    <tr>
        <td colspan="2" style="text-align:center">
            <p>Set image size : <asp:TextBox ID="txtSize" runat="server" Width="30px" MaxLength="3" /> pixel</p>
            <asp:Button ID="btnSaveImage" Text="Save Image" runat="server" OnClick="btnSaveImage_Click" /><br />
            <asp:Label ID="lblValidate" runat="server" Font-Size="X-Small" ForeColor="red" />
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <asp:Label ID="lblResult" runat="server" ForeColor="red" />
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="ObjectDataSource1"
                 OnItemUpdated="DetailsView1_ItemUpdated" Width="920px" BackColor="LightGoldenrodYellow" BorderColor="Tan" 
                 BorderWidth="1px" ForeColor="Black" GridLines="None" CellPadding="10" Caption="Product Details" CaptionAlign="Top" DataKeyNames="ProductID" EmptyDataText="n/a">
                <Fields>
                    <asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
                    <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
                    <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
                    <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
                    <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
                    <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:HyperLink ID="lbtnEdit" runat="server" Text="Edit Product In Details" 
                                        NavigateUrl='<%# "EditProductInDetail.aspx?id=" + DataBinder.Eval(Container.DataItem, "ProductID") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Fields>
                <FooterStyle BackColor="Tan" />
                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
                <HeaderStyle BackColor="Tan" Font-Bold="True" />
                <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                <AlternatingRowStyle BackColor="PaleGoldenrod" />                
            </asp:DetailsView><br />
            
        </td>
    </tr>
</table>
    <asp:ObjectDataSource ID="ObjectDataSourceWareHouse" runat="server" SelectMethod="GetAll" TypeName="Bll.WareHouseBll">
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSourceCategory" runat="server" SelectMethod="GetByWareHouseID" TypeName="Bll.CategoryBll">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlstWareHouse" Name="wareHouseID" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>    
    <asp:ObjectDataSource ID="ObjectDataSourceProduct" runat="server" SelectMethod="GetByCategoryID" TypeName="Bll.ProductBll" DataObjectTypeName="Entities.ProductInfo" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" UpdateMethod="Update">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlstCategory" Name="categoryID" PropertyName="SelectedValue"
                Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="Entities.ProductInfo"
        DeleteMethod="Delete" InsertMethod="Insert" SelectMethod="GetByID" TypeName="Bll.ProductBll"
        UpdateMethod="Update">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlstProduct" Name="productID" PropertyName="SelectedValue"
                Type="String" DefaultValue="1" />
        </SelectParameters>
    </asp:ObjectDataSource>

</asp:Content>

